From 8b1c91886740ba08f51b709dbf831446dba09db7 Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Wed, 19 Jun 2013 13:37:40 -0500 Subject: [PATCH] filechooser: In testfilechooser, add buttons to get the selection and the current name --- tests/testfilechooser.c | 51 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/tests/testfilechooser.c b/tests/testfilechooser.c index fdee032475..7959411ed9 100644 --- a/tests/testfilechooser.c +++ b/tests/testfilechooser.c @@ -396,6 +396,47 @@ set_filename_existing_nonexistent_cb (GtkButton *button, set_filename (chooser, "/usr/nonexistent"); } +static void +get_selection_cb (GtkButton *button, + GtkFileChooser *chooser) +{ + GSList *selection; + + selection = gtk_file_chooser_get_uris (chooser); + + g_print ("Selection: "); + + if (selection == NULL) + g_print ("empty\n"); + else + { + GSList *l; + + for (l = selection; l; l = l->next) + { + char *uri = l->data; + + g_print ("%s\n", uri); + + if (l->next) + g_print (" "); + } + } + + g_slist_free_full (selection, g_free); +} + +static void +get_current_name_cb (GtkButton *button, + GtkFileChooser *chooser) +{ + char *name; + + name = gtk_file_chooser_get_current_name (chooser); + g_print ("Current name: %s\n", name ? name : "NULL"); + g_free (name); +} + static void unmap_and_remap_cb (GtkButton *button, GtkFileChooser *chooser) @@ -682,6 +723,16 @@ main (int argc, char **argv) g_signal_connect (button, "clicked", G_CALLBACK (set_filename_existing_nonexistent_cb), dialog); + button = gtk_button_new_with_label ("Get selection"); + gtk_container_add (GTK_CONTAINER (vbbox), button); + g_signal_connect (button, "clicked", + G_CALLBACK (get_selection_cb), dialog); + + button = gtk_button_new_with_label ("Get current name"); + gtk_container_add (GTK_CONTAINER (vbbox), button); + g_signal_connect (button, "clicked", + G_CALLBACK (get_current_name_cb), dialog); + button = gtk_button_new_with_label ("Unmap and remap"); gtk_container_add (GTK_CONTAINER (vbbox), button); g_signal_connect (button, "clicked", -- 2.30.2